﻿@model Amazon.Checkout.ViewModels.ShippingListViewModel

@using Amazon.Checkout.Helpers;

@{ Layout.Title = T("Manage Shipping Methods").ToString(); }

@Html.ValidationSummary()
@using (Html.BeginFormAntiForgeryPost())
{   
    <div class="manage">@Html.ActionLink(T("Create New Shipping Method").ToString(), "New", new { }, new { @class = "button primaryAction" })</div>
    
    <fieldset>
        <table class="items" summary="@T("This is a table of the Amazon shipping methods currently available.")">
            <colgroup>
                <col id="Col1" />
                <col id="Col2" />
                <col id="Col3" />
                <col id="Col4" />
                <col id="Col5" />
                <col id="Col6" />
            </colgroup>
            <thead>
                <tr>
                    <th scope="col">@T("Shipping Label")</th>
                    <th scope="col">@T("Shipment Type")</th>
                    <th scope="col">@T("Shipment Rate")</th>
                    <th scope="col">@T("Service Level")</th>
                    <th scope="col">@T("PO Box Supported")</th>
                    <th scope="col">@T("Actions")</th>
                </tr>
            </thead>
            @foreach (var shipping in Model.Shippings)
            {
            <tr>
                <td>@Html.ActionLink(@shipping.DisplayableShippingLabel, "Edit", new { shippingId = @shipping.Id })</td>  
                <td>@switch (shipping.ShipmentRateType)
                    {
                       case "item":
                            @T("Item Based Rate")
                            break;
                       case "weight":
                            @T("Weight Based Rate")
                            break;                       
                       default:
                            @T("Shipment Based Rate")
                            break;
                    }
                 </td>
                <td>@switch (shipping.ShipmentRateType)
                    {
                       case "item":
                            @string.Format("{0:0.000000}", @shipping.ItemQuantityBasedShippingRate)
                            break;
                       case "weight":
                            @string.Format("{0:0.000000}", @shipping.WeightBasedShippingRate)
                            break;                       
                       default:
                            @string.Format("{0:0.000000}", @shipping.ShipmentBasedShippingRate)
                            break;
                    }
                 </td>  
                <td>@Enum.GetName(typeof(AmazonCheckout.ServiceLevel), @shipping.ServiceLevel)</td>
                <td>@(shipping.PoBoxSupported ? "Yes" : "No")</td>
                <td>
                    @Html.ActionLink("Edit", "Edit", new { shippingId = @shipping.Id }) |
                    @Html.ActionLink("Delete", "Delete", new { shippingId = @shipping.Id }) 
                </td>
            </tr>
            }
        </table>
    </fieldset>
}
